import pygame

class Bullet(pygame.sprite.Sprite):
    def __init__(self, filename,strength,blood,speed,angle,size,screen, plane, is_hero=True):
        pygame.sprite.Sprite.__init__(self)


        self.screen = screen
        self.plane = plane
        
        self.image = pygame.image.load(filename)
        self.image = pygame.transform.scale(self.image, (size, size))
        self.limit = 0
        
        if is_hero:
            self.image = pygame.transform.rotate(self.image, angle)
        else:
            self.image = pygame.transform.rotate(self.image, angle)
            self.limit = self.screen.get_height()

        self.strength = strength
        self.blood = blood
        self.speed = speed
        
        self.rect = self.image.get_rect()
        
        if is_hero:
            self.rect.midbottom = self.plane.rect.midtop
        else:
            self.rect.midbottom = self.plane.rect.midbottom
        
        
    def display(self):
        self.screen.blit(self.image, self.rect)

    def update(self):
        self.rect.y += self.speed
        self.display()

        if self.rect.y == self.limit:
            self.kill()
            return